package com.github.ilioili.justdoit.model.dao;

import android.database.SQLException;

import com.github.ilioili.justdoit.model.pojo.Category;
import com.github.ilioili.justdoit.util.sql.DbUtil;
import com.github.ilioili.justdoit.util.sql.SqlCallback;

import java.util.List;

/**
 * Created by User on 16/6/23.
 */
public class CategoryDao extends BaseDao {
    public static void getAllCategory(final SqlCallback<List<Category>> callback) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                post(callback, DbUtil.getList(Category.class));
            }
        }).start();
    }

    public static boolean insert(Category category) {
        try {
            DbUtil.insert(category);
            return true;
        } catch (SQLException e) {
            return false;
        }
    }

}
